package com.xzd.common.style.excel;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.util.HSSFColor;

public class HSSFCustomDefaultStyle extends HSSFCustomStyle {
	
	
	@Override
	public HSSFCellStyle getMainTitleCellStyle() {
		HSSFCellStyle cellStyle;
		
		if(mainTitleCellStyle == null) {
			if(mainTitleFont == null) {
				mainTitleFont = wb.createFont();
			}
			
			mainTitleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			mainTitleFont.setColor(HSSFColor.DARK_RED.index);
			mainTitleFont.setFontHeightInPoints((short)28);
		    	    
		    
		    cellStyle = wb.createCellStyle();
		   
		    cellStyle.setFont(mainTitleFont);
		    cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
		    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
		    
		    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		    cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		} else {
			cellStyle = mainTitleCellStyle;
		}
		
		return cellStyle;
	}

	@Override
	public HSSFCellStyle getTwoLevelTitleCellStyle() {
		HSSFCellStyle cellStyle;
		
		if(twoLevelTitleCellStyle == null) {
			if(twoLevelTitleFont == null) {
				twoLevelTitleFont = wb.createFont();
			}
			
			twoLevelTitleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
			twoLevelTitleFont.setColor(HSSFColor.GREEN.index);
			twoLevelTitleFont.setFontHeightInPoints((short)16);
		    	    
		    
		    cellStyle = wb.createCellStyle();
		   
		    cellStyle.setFont(twoLevelTitleFont);
		    cellStyle.setFillForegroundColor(HSSFColor.AQUA.index);
		    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
		    
		    cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		} else {
			cellStyle = twoLevelTitleCellStyle;
		}
		
		return cellStyle;
	}

	@Override
	public HSSFCellStyle getThreeLevelTitleCellStyle() {
		HSSFCellStyle cellStyle;
		
		if(threeLevelTitleCellStyle == null) {
			if(threeLevelTitleFont == null) {
				threeLevelTitleFont = wb.createFont();
			}
			
			threeLevelTitleFont.setFontHeightInPoints((short)14);
		    	    
		    cellStyle = wb.createCellStyle();
		   
		    cellStyle.setFont(threeLevelTitleFont);
		    
		    cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		} else {
			cellStyle = threeLevelTitleCellStyle;
		}
		
		return cellStyle;
	}

	@Override
	public HSSFCellStyle getGridContentCellStyle() {
		HSSFCellStyle cellStyle;
		
		if(gridContentCellStyle == null) { 
			if(gridContentFont == null) {
				gridContentFont = wb.createFont();
			}
			
			gridContentFont.setFontHeightInPoints((short)12);
		 
		    cellStyle = wb.createCellStyle();
		    
		    cellStyle.setFont(gridContentFont);
		    
		    cellStyle.setBorderBottom((short)1);
		    cellStyle.setBorderLeft((short)1);
		    cellStyle.setBorderRight((short)1);
		    cellStyle.setBorderTop((short)1);
		    
		    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		    cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		} else {
			cellStyle = gridContentCellStyle;
		}
		
		return cellStyle;
	}

	@Override
	public HSSFCellStyle getGridTitleCellStyle() {
		HSSFCellStyle cellStyle;
		
		if(gridTitleCellStyle == null) {
			if(gridTitleFont == null) {
				gridTitleFont = wb.createFont();
			}
			gridTitleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);	    
			gridTitleFont.setFontHeightInPoints((short)13);
		    
		    cellStyle = wb.createCellStyle();
		   
		    cellStyle.setFont(gridTitleFont);
		    cellStyle.setFillForegroundColor(HSSFColor.ORANGE.index);
		    cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
		    
		    cellStyle.setBorderBottom((short)1);
		    cellStyle.setBorderLeft((short)1);
		    cellStyle.setBorderRight((short)1);
		    cellStyle.setBorderTop((short)1);
		    
		    cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
		    cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
		} else {
			cellStyle = gridTitleCellStyle;
		}
		
		return cellStyle;
	}
	
	
	
	
	
}
